/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/

#include "stdafx.h"
#include "list矢量插座.h"
#include "Context/当前默认操作数据.h"



using namespace std;



#include "list物体插座.h"
#include "list数值插座.h"
#include "list元素插座.h"
#include "list物理物体插座.h"
#include "../C_数值插座.h"
#include "../C_粒子插座.h"

//#include "../C_物理物体插座.h"
#include "../通用插座.h"
#include "../../节点树.h"

#include <系统/多线程.h>
#include <ppl.h>





template<typename T1, typename T2>
inline void f_vec3数据转换拷贝(T1& 目标, const T2& 源) {
	uint32 num = uint32(源.size());
	目标.resize(num);

	auto* p1 = 源.data();
	auto* p2 = 目标.data();
	//#pragma loop(on_vector)
//#pragma omp parallel for
	for (uint32 i = 0; i < num; ++i) {
		vec_转换(&p2[i], &p1[i]);
	}
}



template<typename T>
Inline void f_矢量数据载入(std::vector<T>& data, FILE* f) {
	uint64 num = 0;
	fread(&num, sizeof(uint64), 1, f);
	if (num) {
		data.resize(num);
		fread(data.data(), sizeof(T), 1, f);
	}
}

template<typename T>
Inline void f_写出矢量数据(const std::vector<T>& data, FILE* f) {
	uint64 num = data.size();
	fwrite(&num, sizeof(uint64), 1, f);
	if (num) {
		fwrite(data.data(), sizeof(T), 1, f);
	}
}








C_Vector1D_Vec2插座::C_Vector1D_Vec2插座(wstring name) :C_插座基类(name, E_值类型::e_Type_Vec2_Array1D)
{

}

C_Vector1D_Vec2插座::~C_Vector1D_Vec2插座(){

}

void * C_Vector1D_Vec2插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		
	} else {
		//m_Value.resize(1);
		//m_Value[0] = m_默认值;
	}
	return &m_Value;
}

void C_Vector1D_Vec2插座::f_setData(void * data, uint8 线程ID) {

}

bool C_Vector1D_Vec2插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case e_Type_Vec2:
	case e_Type_Vec2_Array1D:
		return true;
	}
	return false;
}

void C_Vector1D_Vec2插座::f_resize(uint32 size) {
}

std::string C_Vector1D_Vec2插座::f_构建变量代码(int32 loc) {
	uint16 num = f_getLinkNum();
	assert(!m_是否为输出插座);
	if (num) {
		std::string code;
		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_vec2s";

		for (uint16 i = 0; i < num; ++i) {
			C_插座基类* socket = f_getLinkOutSocket(i);

			switch (socket->m_Type) {
			case e_Type_Vec2: {
				code += "f_JIT_Fun_vec2_push_back(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			case e_Type_Vec2_Array1D: {
				code += "f_JIT_Fun_vec2_insert(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
				break;
			}
			
			}
		}

		m_pNode->m_Code += code;
	}
	else {
		m_Code = C_插座基类::f_构建变量代码(loc);
	}
	
	return m_Code;
}

void C_Vector1D_Vec2插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<vec2>(m_Value, f);
}

void C_Vector1D_Vec2插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<vec2>(m_Value, f);
}


std::string f_代码构建_Vec2_1D插座_类型转换为新变量(C_插座基类& socket, C_节点树* rt, std::string& 新变量名称) {
	uint16 num = socket.f_getLinkNum();

	std::string code;

	code = "";

	新变量名称 += "new_val_to_vec2s";
	code += "void* " + 新变量名称 + " = f_JIT_Fun_vec2_alloc(0,0,0,{});\n";

	for (uint16 i = 0; i < num; ++i) {
		C_插座基类* sp = socket.f_getLinkOutSocket(i);
		if (sp) {
			switch (sp->m_Type) {
			case e_Type_Vec2: {
				code += "f_JIT_Fun_vec2_push_back(" + 新变量名称 + ", " + sp->f_getCode(0) + ");\n";
				break;
			}
			case e_Type_Vec2_Array1D: {
				code += "f_JIT_Fun_vec2_insert(" + 新变量名称 + ", " + sp->f_getCode(0) + ");\n";
				break;
			}
			}
		}
	}

	return code;
}





C_Vec2_1D插座::C_Vec2_1D插座(std::wstring name) : C_插座基类(name, E_值类型::e_Type_Vec2_1D) {
	m_默认值 = (S_Vec2Array*)f_core_array_new(1, sizeof(vec2));
	m_转换值 = (S_Vec2Array*)f_core_array_new(1, sizeof(vec2));
	m_Value = m_默认值;
}

C_Vec2_1D插座::~C_Vec2_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
	C_插座基类::~C_插座基类();
}

void* C_Vec2_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_Vec2_1D: return socket->f_getData(0);
			case E_值类型::e_Type_Vec2: {
				m_转换值->ptr_userData[0] = DEF_Vec2插座数据(socket, 0);
				break;
			}

			case E_值类型::e_Type_F32: {
				float32 v = DEF_F32插座数据(socket, 0);
				m_转换值->ptr_userData[0] = {v,v};
				break;
			}
			default:
				return m_默认值;
		}

		return m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_Vec2_1D插座::f_setData(void* data, uint8 线程ID) {
	//m_Value = (S_Vec2Array*)data;
}

void C_Vec2_1D插座::f_绑定指针(void* data) {
	m_Value = (S_Vec2Array*)data;
	m_映射指针 = true;
}

bool C_Vec2_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case e_Type_F32:
	case e_Type_Vec2:
	case e_Type_Vec3:
	case e_Type_Vec4:
	case e_Type_Vec2_1D:
	case e_Type_Vec3_1D:
	case e_Type_Array:
		return true;
	}
	return false;
}

std::string C_Vec2_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(0);
	if (socket) {
		if (socket->m_Type == e_Type_Vec2_1D || socket->m_Type == e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_vec2s";
		code += "S_Vec2Array* " + m_Code + ";\n";
		switch (socket->m_Type) {
		case e_Type_Vec2:
		case e_Type_Vec3: 
		case e_Type_Vec4: {
			code += m_Code + " = f_vec2_array_fromV_alloc((float32*)&" + socket->f_getCode(loc) + ");\n";
			break;
		}
		case E_值类型::e_Type_Vec3_1D: {
			code += m_Code + " = " + DEF_S(f_vec2_array_fromV3s_alloc)"(" + socket->f_getCode(loc) + "); \n";
			break;
		}
		case E_值类型::e_Type_F32:
			code += m_Code + " = " + DEF_S(f_vec2_array_fromV_alloc)"(&" + socket->f_getCode(loc) + ");\n";
			break;
		default:
			m_Code = "";
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

void C_Vec2_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	fread(m_默认值->ptr_userData, sizeof(vec2), 1, f);
}

void C_Vec2_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	fwrite(m_默认值->ptr_userData, sizeof(vec2), 1, f);
}








C_iVec2_1D插座::C_iVec2_1D插座(std::wstring name) : C_插座基类(name, E_值类型::e_Type_iVec2_1D) {
	m_默认值 = (S_iVec2Array*)f_core_array_new(1, sizeof(ivec2));
	m_转换值 = (S_iVec2Array*)f_core_array_new(1, sizeof(ivec2));
	m_Value = m_默认值;
}

C_iVec2_1D插座::~C_iVec2_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
	C_插座基类::~C_插座基类();
}

void* C_iVec2_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
		case E_值类型::e_Type_Array:
		case E_值类型::e_Type_iVec2_1D: return socket->f_getData(0);
		case E_值类型::e_Type_Vec2: {
			auto v = DEF_Vec2插座数据(socket, 0);
			m_转换值->ptr_userData[0] = {int32(v.x), int32(v.y)};
			break;
		}

		case E_值类型::e_Type_F32: {
			float32 v = DEF_F32插座数据(socket, 0);
			m_转换值->ptr_userData[0] = {int32(v),int32(v)};
			break;
		}
		}

		return m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}
	
	return m_Value;
}

void C_iVec2_1D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_iVec2Array*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}
}

void C_iVec2_1D插座::f_绑定指针(void* data) {
	m_Value = (S_iVec2Array*)data;
	m_映射指针 = true;
}

bool C_iVec2_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
		case e_Type_Vec2:
		case e_Type_Vec3:
		case e_Type_Vec4:
		case e_Type_I32_1D:
		case e_Type_Vec2_1D:
		case e_Type_Vec3_1D:
		case e_Type_iVec2_1D:
		case e_Type_Array:
			return true;
	}
	return false;
}

std::string C_iVec2_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	if (socket) {
		if (socket->m_Type == e_Type_iVec2_1D || socket->m_Type == e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_ivec2s";

		code += DEF_S(S_iVec2Array*)" " + m_Code + " = " + f_代码构建_创建Array(E_值类型::e_Type_iVec2_1D, "0");
		switch (socket->m_Type) {
		case e_Type_Vec2:
		case e_Type_Vec3: 
		case e_Type_Vec4: {
			//code += "S_iVec2Array* " + m_Code + " = f_vec2_array_fromV_alloc((float32*)&" + socket->f_getCode() + ");\n";
			break;
		}
		case E_值类型::e_Type_I32_1D: {
			code += DEF_S(f_array_iVec2sfromI32s)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
			break;
		}
		case E_值类型::e_Type_Vec3_1D: {
			//code += "S_iVec2Array* " + m_Code + " = f_vec2_array_fromV3s_alloc(" + socket->f_getCode() + ");\n";
			break;
		}
		default:
			m_Code = "";
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

void C_iVec2_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	fread(m_默认值->ptr_userData, sizeof(ivec2), 1, f);
}

void C_iVec2_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	fwrite(m_默认值->ptr_userData, sizeof(ivec2), 1, f);
}








C_uVec2_1D插座::C_uVec2_1D插座(std::wstring name) : C_插座基类(name, E_值类型::e_Type_uVec2_1D) {
	m_默认值 = (S_uVec2Array*)f_core_array_new(1, sizeof(uvec2));
	m_转换值 = (S_uVec2Array*)f_core_array_new(1, sizeof(uvec2));
	m_Value = m_默认值;
}

C_uVec2_1D插座::~C_uVec2_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
	C_插座基类::~C_插座基类();
}

void* C_uVec2_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
		case  E_值类型::e_Type_Array:
		case E_值类型::e_Type_uVec2_1D: return socket->f_getData(0);
		case E_值类型::e_Type_Vec2: {
			auto v = DEF_Vec2插座数据(socket, 0);
			m_转换值->ptr_userData[0] = {uint32(v.x), uint32(v.y)};
			break;
		}

		case E_值类型::e_Type_F32: {
			float32 v = DEF_F32插座数据(socket, 0);
			m_转换值->ptr_userData[0] = {uint32(v),uint32(v)};
			break;
		}
		}

		return m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_uVec2_1D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_uVec2Array*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = (S_uVec2Array*)m_默认值;
		m_映射指针 = false;
	}
}

bool C_uVec2_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case e_Type_Vec2:
	case e_Type_Vec3:
	case e_Type_Vec4:
	case e_Type_Vec2_1D:
	case e_Type_Vec3_1D:
	case e_Type_iVec2_1D:
	case e_Type_uVec2_1D:
	case e_Type_Array:
	case E_值类型::e_插座Type_引用数据:
		return true;
	}
	return false;
}

std::string C_uVec2_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	if (socket) {
		if (socket->m_Type == e_Type_uVec2_1D || socket->m_Type == e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_ivec2s";

		//code += DEF_S(S_UIVec2Array*)" " + m_Code + " = " + f_代码构建_创建Array(E_值类型::e_Type_UIVec2_1D, "0");
		switch (socket->m_Type) {
		case e_Type_Vec2:
		case e_Type_Vec3: 
		case e_Type_Vec4: {
			//code += "S_iVec2Array* " + m_Code + " = f_vec2_array_fromV_alloc((float32*)&" + socket->f_getCode() + ");\n";
			break;
		}
		case E_值类型::e_Type_Vec3_1D: {
			//code += "S_iVec2Array* " + m_Code + " = f_vec2_array_fromV3s_alloc(" + socket->f_getCode() + ");\n";
			break;
		}
		default:
			m_Code = "";
		}

		//m_pNode->m_ReleaseCode += f_代码构建_销毁Array(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

void C_uVec2_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	fread(m_默认值->ptr_userData, sizeof(uvec2), 1, f);
}

void C_uVec2_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	fwrite(m_默认值->ptr_userData, sizeof(uvec2), 1, f);
}







C_Vector1D_Vec3插座::C_Vector1D_Vec3插座(wstring name) :C_插座基类(name, E_值类型::e_Type_Vec3_Array1D) {
	m_Value.resize(1);
}

C_Vector1D_Vec3插座::~C_Vector1D_Vec3插座() {
}

void* C_Vector1D_Vec3插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {
			return dynamic_cast<C_Vector1D_Vec3插座*>(socket)->f_getData(线程ID);
		}else if (socket->m_Type == E_值类型::e_插座Type_Vec3i_Array1D) {
			auto i3 = *DEF_转换为Array_iVec3插座数据(socket);

			uint32 num = uint32(i3.size());
			m_Value.resize(num);

			ivec3* p1 = i3.data();
			vec3* p2 = m_Value.data();

			for (uint32 i = 0; i < num; ++i) {
				vec_转换(&p2[i], &p1[i]);
			}

		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_1D) {
			auto& data = *DEF_Vec3插座_1D数据(socket, 0);
			m_Value.resize(1);
			if(data.count) {
				m_Value[0] = data.ptr_userData[0];
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3) {
			auto data = DEF_Vec3插座数据(socket, 0);
			m_Value.resize(1);
			m_Value[0] = data;
		}
		else if (socket->m_Type == E_值类型::e_Type_F32_Array1D) {
			auto& data = *DEF_F32_Array1D插座数据(socket, 0);
			uint32 num = uint32(data.size());
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.data();

			for (uint32 i = 0; i < num; ++i) {
				p1[i].x = data[i];
				p1[i].y = data[i];
				p1[i].z = data[i];
			}
			
		}
		else if (socket->m_Type == E_值类型::e_Type_F32) {
			auto data = DEF_F32插座数据(socket, 0);
			m_Value.resize(1);
			m_Value[0].x = data;
			m_Value[0].y = data;
			m_Value[0].z = data;
		}
		else if (socket->m_Type == E_值类型::e_插座Type_Line) {
			auto data = *DEF_线段插座数据(socket, 0);
			m_Value.resize(2);
			m_Value[0] = data.begin;
			m_Value[1] = data.end;
		}
		else if (socket->m_Type == E_值类型::e_插座Type_Line_Array1D) {
			auto data = *DEF_线段_1D插座数据(socket, 0);
			uint32 num = uint32(data.size());
			m_Value.resize(num * 2);

			for (uint32 i = 0; i < num; ++i) {
				m_Value[i * 2] = data[i].begin;
				m_Value[i * 2 + 1] = data[i].end;
			}
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//m_Value.clear();

			//bool 引用接引用 = (data.m_插座类型 == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type)
			{
			case E_值类型::e_Type_Vec3_Array1D:
				return data->m_Data;
			case E_值类型::e_Type_Vec3:
			{
				m_Value.resize(1);
				m_Value[0] = *((vec3*)data->m_Data);
			}
			break;
			default:
				break;
			}
			
		}
		else {
			m_Value.resize(1);
			m_Value[0] = m_默认值;
		}
	}
	else {
		//m_Value.resize(1);
		//m_Value[0] = m_默认值;
	}
	return &m_Value;
}

vector<vec3>* C_Vector1D_Vec3插座::f_getVec3_1D(const int64& ID, uint8 线程ID) {
	auto data = DEF_Vec3_Array1D插座数据(this);
	if (data) {
		return data;
	}
	return nullptr;
}

void C_Vector1D_Vec3插座::f_setData(void* data, uint8 线程ID) {
	S_引用插座数据映射* mapData = (S_引用插座数据映射*)(data);

	if (mapData->m_Type == E_值类型::e_Type_Vec3) {
		if (mapData->m_添加方式 == E_数据赋值方式::e_赋值_添加) {
			m_Value.push_back( *((vec3*)(mapData->m_Data)) );
		}

		return;
	}
	else if (mapData->m_Type == E_值类型::e_Type_Vec3_Array1D) {
		cout << "施工中" << endl;
		if (mapData->m_添加方式 == E_数据赋值方式::e_赋值_添加) {
			auto& insData = *((vector<vec3>*)(mapData->m_Data));
			m_Value.insert(m_Value.end(), insData.begin(), insData.end());
		}
		return;
	}

	m_Value = *((vector<vec3>*)data);
}

std::string C_Vector1D_Vec3插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	if (socket) {
		if (socket->m_Type == e_Type_Vec3_Array1D) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_vec3s";
		code = f_代码构建_创建vec3数组(m_Code);

		switch (socket->m_Type) {
		case e_Type_Vec3: {
			code += "f_JIT_Fun_vec3_push_back(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
			m_pNode->m_ReleaseCode += "f_JIT_Fun_vec3_free(" + m_Code + ");\n";
			break;
		}
		case e_Type_Vec3_1D: {
			code += "S_Vec3Array* " + m_Code + " = f_vec3_array_过度函数_从CXX_alloc(" + socket->f_getCode(loc) + ");\n";
			m_pNode->m_ReleaseCode += "f_core_array_free((S_Array*)" + m_Code + ");\n";
			break;
		}
		}
		//m_pNode->m_Code += code;
		
	}
	else {
		m_Code = C_插座基类::f_构建变量代码(loc);
	}
	
	return code;
}

void C_Vector1D_Vec3插座::f_resize(uint32 size) {
	m_Value.resize(size);
}

void C_Vector1D_Vec3插座::f_reset() {
	m_Value.resize(1);
	m_Value[0] = m_默认值;
}

void C_Vector1D_Vec3插座::f_释放数据(){
	m_Value.clear();
}

void C_Vector1D_Vec3插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<vec3>(m_Value, f);
}

void C_Vector1D_Vec3插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<vec3>(m_Value, f);
}







C_Vec3_1D插座::C_Vec3_1D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Vec3_1D) {
	m_默认值 = f_vec3_array_alloc(1);
	m_转换值 = f_vec3_array_alloc(1);
	m_Value = m_默认值;

	m_默认值->ptr_userData[0] = {};
	m_转换值->ptr_userData[0] = {};
}

C_Vec3_1D插座::~C_Vec3_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
}

S_GPU内存块索引& C_Vec3_1D插座::f_getGPU块(uint8 线程ID, bool 更新) {
	C_插座基类::f_getGPU块(线程ID, 更新);
	if (!m_GPU缓存.m_Buf) {
		m_GPU缓存 = f_buf_alloc(f_NodeCtx_get默认场景()->m_光追后端->m_Vec3动态属性, 1);
	}

	if (更新) {
		S_Vec3Array* data = (S_Vec3Array*)f_getData(线程ID);
		f_gbuf_fill(m_GPU缓存, data->ptr_userData, 0, data->count);
	}
	return m_GPU缓存;
}

S_GPU内存块索引& C_Vec3_1D插座::f_downGPU块(uint8 线程ID, bool 更新) {
	S_Vec3Array* data = (S_Vec3Array*)f_getData(线程ID);
	if (m_GPU缓存.m_Buf) {
		f_buf_down(m_GPU缓存, (S_Array*)data);
	}
	return m_GPU缓存;
}

void* C_Vec3_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array: 
			case E_值类型::e_Type_Vec3_1D: return socket->f_getData(0);

			case E_值类型::e_Type_Vec3: {
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = DEF_Vec3插座数据(socket, 0);
				break;
			}
			case E_值类型::e_Type_iVec3: {
				auto val = DEF_iVec3插座数据(socket);
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = { (float32)val.x, (float32)val.y, (float32)val.z};
				break;
			}

			case E_值类型::e_Type_F32: {
				float32 v = DEF_F32插座数据(socket, 0);
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = {v,v,v};
				break;
			}
			case E_值类型::e_Type_I32: {
				int32 v = DEF_I32插座数据(socket, 0);
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = { float32(v),float32(v),float32(v) };
				break;
			}
			case E_值类型::e_Type_I8: {
				int8 v = DEF_I8插座数据(socket);
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = { float32(v),float32(v),float32(v) };
				break;
			}
			case E_值类型::e_Type_UI32: {
				uint32 v = DEF_UI32插座数据(socket, 0);
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = { float32(v),float32(v),float32(v) };
				break;
			}
			case E_值类型::e_Type_I32_1D: {
				auto* v = DEF_I32插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					auto 单个值 = float32(v->ptr_userData[i]);
					m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
				}
				break;
			}
			case E_值类型::e_Type_I8_1D: {
				auto* v = DEF_I8插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					auto 单个值 = float32(v->ptr_userData[i]);
					m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
				}
				break;
			}
			case E_值类型::e_Type_F32_1D: {
				auto* v = DEF_F32插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					auto 单个值 = (v->ptr_userData[i]);
					m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
				}
				break;
			}
			case e_Type_iVec3_1D: {
				auto* v = DEF_iVec3插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					m_转换值->ptr_userData[i] = { (float32)v->ptr_userData[i].x , (float32)v->ptr_userData[i].y, (float32)v->ptr_userData[i].z };
				}
				break;
			}
			default:
				std::cout<<"error:vec3插座输入数据没有实现输入转换类型"<<std::endl;
		}

		return m_转换值;
	} 
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}
	
	return m_Value;
}

void C_Vec3_1D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_Vec3Array*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}
}

std::string C_Vec3_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	auto* rt = f_getNode()->f_getThis节点树();

	if (socket) {
		if (socket->m_Type == e_Type_Vec3_1D || socket->m_Type == E_值类型::e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_vec3s";
		
		auto 输入的数据 = socket->f_getCode(loc);

		switch (socket->m_Type) {
		case e_Type_F32: {
			code = f_代码构建_创建vec3_Array(m_Code, "1");
			code += m_Code + "->ptr_userData[0] = {" + socket->f_getCode(loc) + ", " + socket->f_getCode(loc) + ", " + socket->f_getCode(loc) + "};\n";
			break;
		}
		case e_Type_I8:
		case e_Type_I32:
		case e_Type_UI32: {
			code = f_代码构建_创建vec3_Array(m_Code, "1");
			code += m_Code + "->ptr_userData[0] = {(float32)" + socket->f_getCode(loc) + 
												", (float32)" + socket->f_getCode(loc) + 
												", (float32)" + socket->f_getCode(loc) + "};\n";
			break;
		}
		case e_Type_Vec3: {
			code = f_代码构建_创建vec3_Array(m_Code, "0");
			code += "f_core_array_push_back((S_Array*)" + m_Code + ", (uint8*)&" + socket->f_getCode(loc) + ");\n";
			break;
		}
		case e_Type_Vec4: {
			code += "S_Vec3Array* " + m_Code + " = f_vec3_array_fromV4_alloc(" + socket->f_getCode(loc) + ");\n";
			break;
		}
		case e_Type_iVec3: 
		case e_Type_iVec4: {
			code += DEF_S(S_Vec3Array*)" " + m_Code + " = " + f_代码构建_创建Array(E_值类型::e_Type_Vec3_1D, "1");
			code += m_Code + "->ptr_userData[0] = {(float32)(" + 输入的数据 + ".x), (float32)(" + 输入的数据 + ".y), (float32)(" + 输入的数据 + ".z)}; \n";
			break;
		}
		case e_Type_F32_1D: {
			code += DEF_S(S_Vec3Array*)" " + m_Code + " = " + DEF_S(f_array_Vec3fromF32s_alloc)"(" + 输入的数据 + ");\n";
			break;
		}
		case e_Type_I32_1D: {
			code += DEF_S(S_Vec3Array*)" " + m_Code + " = " + DEF_S(f_array_Vec3fromI32_alloc)"(" + 输入的数据 + ");\n";
			break;
		}
		case e_Type_I8_1D: {
			code += DEF_S(S_Vec3Array*)" " + m_Code + " = " + DEF_S(f_array_Vec3fromI8_alloc)"(" + 输入的数据 + ");\n";
			break;
		}
		case e_Type_iVec3_1D: {
			code += DEF_S(S_Vec3Array*)" " + m_Code + " = " + DEF_S(f_array_Vec3fromiVec3s_alloc)"(" + 输入的数据 + ");\n";
			break;
		}
		default:
			std::cout<<"err : vec3 array 插座数据转化没有实现对于数据转换类型"<<std::endl;
		}
		
		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
		//auto& JIT参数 = rt->m_节点JIT参数;
		//uint16 常量ID = JIT参数.size();
		//m_Code = "((" + f_node_getDataTypeName(m_Type) + "*)(g参数[" + f_整数值转字符串(常量ID) + "]))";
		//rt->m_节点JIT参数.push_back(f_getData(0));
	}

	return code;
}

bool C_Vec3_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case E_值类型::e_Type_Array:
	case E_值类型::e_Type_I8:
	case E_值类型::e_Type_I32:
	case E_值类型::e_Type_UI32:
	case E_值类型::e_Type_F32:
	case E_值类型::e_Type_iVec3:
	case E_值类型::e_Type_Vec3:
	case E_值类型::e_Type_F32_1D:
	case E_值类型::e_Type_Vec3_1D:
	case E_值类型::e_Type_iVec3_1D:
	case E_值类型::e_Type_I8_1D:
	case E_值类型::e_Type_I32_1D:
	case E_值类型::e_Type_Vec3_Array1D:
		return true;
	}
	return false;
}

void C_Vec3_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	fread(m_默认值->ptr_userData, sizeof(vec3), 1, f);
}

void C_Vec3_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	fwrite(m_默认值->ptr_userData, sizeof(vec3), 1, f);
}

void C_Vec3_1D插座::f_Copy(const C_插座基类* socket) {
	C_插座基类::f_Copy(socket);

	const C_Vec3_1D插座* s = dynamic_cast<const C_Vec3_1D插座*>(socket);
	if (s) {
		f_core_array_copy((S_Array*)m_默认值, (S_Array*)s->m_默认值);
	}
}





C_Vec4_1D插座::C_Vec4_1D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Vec4_1D) {
	m_默认值 = (S_Vec4Array*)f_core_array_new(1, sizeof(vec4));
	m_转换值 = (S_Vec4Array*)f_core_array_new(1, sizeof(vec4));
	m_Value = m_默认值;

	m_默认值->ptr_userData[0] = {0,0,0,1};
	m_转换值->ptr_userData[0] = {0,0,0,1};
}

C_Vec4_1D插座::~C_Vec4_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
	C_插座基类::~C_插座基类();
}

void* C_Vec4_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_Vec4_1D: return socket->f_getData(0);

			case E_值类型::e_Type_Vec4: {
				m_转换值->ptr_userData[0] = *DEF_Vec4插座数据(socket, 0);
				break;
			}

			case E_值类型::e_Type_F32: {
				float32 v = DEF_F32插座数据(socket, 0);
				m_转换值->ptr_userData[0] = {v,v,v,v};
				break;
			}
			
		}

		return m_转换值;
	}
	else if (m_映射指针) {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_Vec4_1D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_Vec4Array*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}
	
}

std::string C_Vec4_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	if (socket) {
		if (socket->m_Type == e_Type_Vec4_1D || socket->m_Type == e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_vec4s";

		switch (socket->m_Type) {
		case e_Type_Vec3: {
			code += "S_Vec4Array* " + m_Code + " = f_vec4_array_fromV3_alloc(" + socket->f_getCode(loc) + ");\n";
			break;
		}
		case e_Type_Vec4: {
			code += "S_Vec4Array* " + m_Code + " = f_vec4_array_fromV4_alloc(" + socket->f_getCode(loc) + ");\n";
			break;
		}
		case e_Type_Vec3_1D: {
			code += "S_Vec4Array* " + m_Code + " = f_vec4_array_alloc(" + socket->f_getCode(loc) + ");\n";
			break;
		}
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

bool C_Vec4_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case E_值类型::e_Type_Vec3:
	case E_值类型::e_Type_Vec3_1D:
	case E_值类型::e_Type_Vec3_Array1D:
	case E_值类型::e_Type_Vec4:
	case E_值类型::e_Type_Vec4_1D:
	case E_值类型::e_Type_Array:
		return true;
	}
	return false;
}

void C_Vec4_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	fread(m_默认值->ptr_userData, sizeof(vec4), 1, f);
}

void C_Vec4_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	fwrite(m_默认值->ptr_userData, sizeof(vec4), 1, f);
}








C_iVec3_1D插座::C_iVec3_1D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_iVec3_1D) {
	m_默认值 = (S_iVec3Array*)f_core_array_new(1, sizeof(ivec3));
	m_转换值 = (S_iVec3Array*)f_core_array_new(1, sizeof(ivec3));
	m_Value = m_默认值;

	m_默认值->ptr_userData[0] = {};
	m_转换值->ptr_userData[0] = {};
}

C_iVec3_1D插座::~C_iVec3_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
}

void* C_iVec3_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_iVec3_1D: return socket->f_getData(0);

			case E_值类型::e_Type_Vec3: {
				auto v = DEF_Vec3插座数据(socket);
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = {(int32)v.x, (int32)v.y, (int32)v.z};
				break;
			}

			case E_值类型::e_Type_F32: {
				float32 v = DEF_F32插座数据(socket);
				m_转换值->ptr_userData[0] = { (int32)v, (int32)v, (int32)v };
				break;
			}
			case E_值类型::e_Type_I32: {
				int32 v = DEF_I32插座数据(socket, 0);
				m_转换值->ptr_userData[0] = { int32(v), int32(v), int32(v) };
				break;
			}
			case E_值类型::e_Type_I8: {
				int8 v = DEF_I8插座数据(socket);
				m_转换值->ptr_userData[0] = { int32(v), int32(v), int32(v) };
				break;
			}
			case E_值类型::e_Type_UI32: {
				uint32 v = DEF_UI32插座数据(socket, 0);
				m_转换值->ptr_userData[0] = { int32(v), int32(v), int32(v) };
				break;
			}
			case E_值类型::e_Type_F32_1D: {
				auto* v = DEF_F32插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					auto 单个值 = int32(v->ptr_userData[i]);
					m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
				}
				break;
			}
			case E_值类型::e_Type_I32_1D: {
				auto* v = DEF_I32插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					auto 单个值 = int32(v->ptr_userData[i]);
					m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
				}
				break;
			}
			case E_值类型::e_Type_I8_1D: {
				auto* v = DEF_I8插座_1D数据(socket);
				f_core_array_resize((S_Array*)m_转换值, v->count);
				for (uint32 i = 0; i < v->count; ++i) {
					auto 单个值 = int32(v->ptr_userData[i]);
					m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
				}
				break;
			}
		}

		return m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}
	
	return m_Value;
}

void C_iVec3_1D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_iVec3Array*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}
	
}

std::string C_iVec3_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	auto* rt = f_getNode()->f_getThis节点树();

	if (socket) {
		if (socket->m_Type == e_Type_iVec3_1D || socket->m_Type == E_值类型::e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_ivec3s";

		auto 输入的数据 = socket->f_getCode(loc);

		code += DEF_S(S_iVec3Array*)" " + m_Code + " = " + f_代码构建_创建Array(E_值类型::e_Type_iVec3_1D, "1");
		switch (socket->m_Type) {
			case e_Type_F32:
			case e_Type_I8:
			case e_Type_I32:
			case e_Type_UI32: {
				code += m_Code + "->ptr_userData[0] = {(int32)" + 输入的数据 +
													", (int32)" + 输入的数据 +
													", (int32)" + 输入的数据 + "};\n";
				break;
			}
			case e_Type_Vec3: 
			case e_Type_Vec4: 
			case e_Type_iVec3:
			case e_Type_iVec4: {
				code += m_Code + "->ptr_userData[0] = {(int32)(" + 输入的数据 + ".x), (int32)(" + 输入的数据 + ".y), (int32)(" + 输入的数据 + ".z)}; \n";
				break;
			}

			case e_Type_I32_1D: {
				code += DEF_S(f_array_iVec3fromI32_alloc)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			case e_Type_I8_1D: {
				code += DEF_S(f_array_iVec3fromI8_alloc)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			case e_Type_F32_1D: {
				code += DEF_S(f_array_iVec3fromF32_alloc)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			case e_Type_Vec3_1D: {
				code += DEF_S(f_array_iVec3fromVec3_alloc)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			default:
				std::cout << "err : vec3 array 插座数据转化没有实现对于数据转换类型" << std::endl;
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

bool C_iVec3_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
		case E_值类型::e_Type_Array:
		case E_值类型::e_Type_I8:
		case E_值类型::e_Type_I32:
		case E_值类型::e_Type_UI32:
		case E_值类型::e_Type_F32:
		case E_值类型::e_Type_iVec3:
		case E_值类型::e_Type_Vec3:
		case E_值类型::e_Type_F32_1D:
		case E_值类型::e_Type_I8_1D:
		case E_值类型::e_Type_I32_1D:
		case E_值类型::e_Type_Vec3_1D:
		case E_值类型::e_Type_iVec3_1D:
			return true;
	}
	return false;
}

void C_iVec3_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	fread(m_默认值->ptr_userData, sizeof(ivec3), 1, f);
}

void C_iVec3_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	fwrite(m_默认值->ptr_userData, sizeof(ivec3), 1, f);
}

void C_iVec3_1D插座::f_Copy(const C_插座基类* socket) {
	C_插座基类::f_Copy(socket);

	const C_iVec3_1D插座* s = dynamic_cast<const C_iVec3_1D插座*>(socket);
	if (s) {
		f_core_array_copy((S_Array*)m_默认值, (S_Array*)s->m_默认值);
	}
}






C_iVec3_2D插座::C_iVec3_2D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_iVec3_2D) {
	m_默认值 = (S_iVec3Array2D*)f_core_array_new(0, sizeof(S_iVec3Array*));
	m_转换值 = (S_iVec3Array2D*)f_core_array_new(0, sizeof(S_iVec3Array*));
	m_Value = m_默认值;

	m_默认值->ptr_userData[0] = {};
	m_转换值->ptr_userData[0] = {};
}

C_iVec3_2D插座::~C_iVec3_2D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
}

void* C_iVec3_2D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_iVec3_2D: return socket->f_getData(0);

			//case E_值类型::e_Type_Vec3: {
			//	auto v = DEF_Vec3插座数据(socket);
			//	f_core_array_resize((S_Array*)m_转换值, 1);
			//	m_转换值->ptr_userData[0] = { (int32)v.x, (int32)v.y, (int32)v.z };
			//	break;
			//}
			//case E_值类型::e_Type_F32: {
			//	float32 v = DEF_F32插座数据(socket);
			//	m_转换值->ptr_userData[0] = { (int32)v, (int32)v, (int32)v };
			//	break;
			//}
			//case E_值类型::e_Type_I32: {
			//	int32 v = DEF_I32插座数据(socket, 0);
			//	m_转换值->ptr_userData[0] = { int32(v), int32(v), int32(v) };
			//	break;
			//}
			//case E_值类型::e_Type_I8: {
			//	int8 v = DEF_I8插座数据(socket);
			//	m_转换值->ptr_userData[0] = { int32(v), int32(v), int32(v) };
			//	break;
			//}
			//case E_值类型::e_Type_UI32: {
			//	uint32 v = DEF_UI32插座数据(socket, 0);
			//	m_转换值->ptr_userData[0] = { int32(v), int32(v), int32(v) };
			//	break;
			//}
			//case E_值类型::e_Type_F32_1D: {
			//	auto* v = DEF_F32插座_1D数据(socket);
			//	f_core_array_resize((S_Array*)m_转换值, v->count);
			//	for (uint32 i = 0; i < v->count; ++i) {
			//		auto 单个值 = int32(v->ptr_userData[i]);
			//		m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
			//	}
			//	break;
			//}
			//case E_值类型::e_Type_I32_1D: {
			//	auto* v = DEF_I32插座_1D数据(socket);
			//	f_core_array_resize((S_Array*)m_转换值, v->count);
			//	for (uint32 i = 0; i < v->count; ++i) {
			//		auto 单个值 = int32(v->ptr_userData[i]);
			//		m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
			//	}
			//	break;
			//}
			//case E_值类型::e_Type_I8_1D: {
			//	auto* v = DEF_I8插座_1D数据(socket);
			//	f_core_array_resize((S_Array*)m_转换值, v->count);
			//	for (uint32 i = 0; i < v->count; ++i) {
			//		auto 单个值 = int32(v->ptr_userData[i]);
			//		m_转换值->ptr_userData[i] = { 单个值 , 单个值 , 单个值 };
			//	}
			//	break;
			//}
			//case E_值类型::e_Type_Vec3_1D: {
			//	auto v = DEF_Vec3插座_1D数据(socket);
			//	if (v->count) {
			//		f_core_array_resize((S_Array*)m_转换值, 1);
			//		m_转换值->ptr_userData[0] = { (int32)v->ptr_userData[0].x, (int32)v->ptr_userData[0].y, (int32)v->ptr_userData[0].z };
			//	}
			//	else {
			//		f_core_array_resize((S_Array*)m_转换值, 1);
			//	}
			//	
			//	break;
			//}
			case E_值类型::e_Type_iVec3_1D: {
				auto v = DEF_iVec3插座_1D数据(socket);
				if (v->count) {
					f_core_array_resize((S_Array*)m_转换值, 1);
					m_转换值->ptr_userData[0] = v;
				}
				else {
					f_core_array_resize((S_Array*)m_转换值, 1);
				}

				break;
			}
		}

		return m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}

	return m_Value;
}

void C_iVec3_2D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_iVec3Array2D*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}

}

std::string C_iVec3_2D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	auto* rt = f_getNode()->f_getThis节点树();

	if (socket) {
		if (socket->m_Type == e_Type_iVec3_2D || socket->m_Type == E_值类型::e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "_ivec3_2Ds";

		auto 输入的数据 = socket->f_getCode(loc);

		code += DEF_S(S_iVec3Array2D*)" " + m_Code + " = " + f_代码构建_创建Array(E_值类型::e_Type_iVec3_2D, "1");
		switch (socket->m_Type) {
			//case e_Type_F32:
			//case e_Type_I8:
			//case e_Type_I32:
			//case e_Type_UI32: {
			//	code += m_Code + "->ptr_userData[0] = {(int32)" + 输入的数据 +
			//		", (int32)" + 输入的数据 +
			//		", (int32)" + 输入的数据 + "};\n";
			//	break;
			//}
			//case e_Type_Vec3:
			//case e_Type_Vec4:
			//case e_Type_iVec3:
			//case e_Type_iVec4: {
			//	code += m_Code + "->ptr_userData[0] = {(int32)(" + 输入的数据 + ".x), (int32)(" + 输入的数据 + ".y), (int32)(" + 输入的数据 + ".z)}; \n";
			//	break;
			//}
			//
			//case e_Type_I32_1D: {
			//	code += m_Code + " = " + DEF_S(f_array_iVec3fromI32_alloc)"(" + socket->f_getCode(loc) + ");\n";
			//	break;
			//}
			//case e_Type_I8_1D: {
			//	code += m_Code + " = " + DEF_S(f_array_iVec3fromI8_alloc)"(" + socket->f_getCode(loc) + ");\n";
			//	break;
			//}
			//case e_Type_F32_1D: {
			//	code += m_Code + " = " + DEF_S(f_array_iVec3fromF32_alloc)"(" + socket->f_getCode(loc) + ");\n";
			//	break;
			//}
			//case e_Type_Vec3_1D: {
			//	code += m_Code + " = " + DEF_S(f_array_iVec3fromVec3_alloc)"(" + socket->f_getCode(loc) + ");\n";
			//	break;
			//}
			case e_Type_iVec3_1D: {
				code += DEF_S(f_array_2DiVec3from1DiVec3_alloc)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			default:
				std::cout << "err : ivec3 2d array 插座数据转化没有实现对于数据转换类型" << std::endl;
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

bool C_iVec3_2D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
		case E_值类型::e_Type_Array:
		//case E_值类型::e_Type_I8:
		//case E_值类型::e_Type_I32:
		//case E_值类型::e_Type_UI32:
		//case E_值类型::e_Type_F32:
		//case E_值类型::e_Type_iVec3:
		//case E_值类型::e_Type_Vec3:
		//case E_值类型::e_Type_F32_1D:
		//case E_值类型::e_Type_I8_1D:
		//case E_值类型::e_Type_I32_1D:
		//case E_值类型::e_Type_Vec3_1D:
		case E_值类型::e_Type_iVec3_1D:
		case E_值类型::e_Type_iVec3_2D:
			return true;
	}
	return false;
}

void C_iVec3_2D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	S_文件块 文件块 = f_file_读取文件块(f);
	if (文件块.m_块类型 == E_节点工程文件块类型::e_工程文件块_插座实例属性) {
		const uint8* 下一次读取数据指针 = 文件块.m_data;
	}
	free(文件块.m_data);
}

void C_iVec3_2D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	auto 文件块 = f_file_构建文件块信息(E_节点工程文件块类型::e_工程文件块_插座实例属性, S_节点数据::g_文件版本号);
	S_UI8Array* 块 = (S_UI8Array*)f_core_array_new(0, sizeof(uint8));

	f_file_保存文件块(f, 文件块, 块);
}

void C_iVec3_2D插座::f_Copy(const C_插座基类* socket) {
	C_插座基类::f_Copy(socket);

	const C_iVec3_2D插座* s = dynamic_cast<const C_iVec3_2D插座*>(socket);
	if (s) {
		//f_core_array_copy((S_Array*)m_默认值, (S_Array*)s->m_默认值);
	}
}






C_Vec3_2D插座::C_Vec3_2D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Vec3_2D) {
	m_默认值 = (S_Vec3Array2D*)f_core_array_new(0, sizeof(S_Vec3Array*), true);
	m_转换值 = (S_Vec3Array2D*)f_core_array_new(0, sizeof(S_Vec3Array*), true);
	m_Value = m_默认值;

	//m_默认值->ptr_userData[0] = {};
	//m_转换值->ptr_userData[0] = {};
}

C_Vec3_2D插座::~C_Vec3_2D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
}

void* C_Vec3_2D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_Vec3_2D: return socket->f_getData(0);

			case E_值类型::e_Type_Vec3_1D: {
				auto v = DEF_Vec3插座_1D数据(socket);
				if (v->count) {
					f_core_array_resize((S_Array*)m_转换值, 1);
					m_转换值->ptr_userData[0] = v;
				}
				else {
					f_core_array_resize((S_Array*)m_转换值, 1);
				}

				break;
			}
		}

		return m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}

	return m_Value;
}

void C_Vec3_2D插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_Vec3Array2D*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}

}

std::string C_Vec3_2D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	auto* rt = f_getNode()->f_getThis节点树();

	if (socket) {
		if (socket->m_Type == e_Type_Vec3_2D || socket->m_Type == E_值类型::e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "_ivec3_2Ds";

		auto 输入的数据 = socket->f_getCode(loc);

		code += DEF_S(S_Vec3Array2D*)" " + m_Code + " = " + f_代码构建_创建Array(E_值类型::e_Type_Vec3_2D, "1");
		switch (socket->m_Type) {
			case e_Type_Vec3_1D: {
				code += DEF_S(f_array_2DVec3from1DVec3_alloc)"(" + m_Code + ", " + socket->f_getCode(loc) + ");\n";
				break;
			}
			default:
				std::cout << "err : ivec3 2d array 插座数据转化没有实现对于数据转换类型" << std::endl;
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

bool C_Vec3_2D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
		case E_值类型::e_Type_Array:
		case E_值类型::e_Type_Vec3_1D:
		case E_值类型::e_Type_Vec3_2D:
			return true;
	}
	return false;
}

void C_Vec3_2D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	S_文件块 文件块 = f_file_读取文件块(f);
	if (文件块.m_块类型 == E_节点工程文件块类型::e_工程文件块_插座实例属性) {
		const uint8* 下一次读取数据指针 = 文件块.m_data;
	}
	free(文件块.m_data);
}

void C_Vec3_2D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	auto 文件块 = f_file_构建文件块信息(E_节点工程文件块类型::e_工程文件块_插座实例属性, S_节点数据::g_文件版本号);
	S_UI8Array* 块 = (S_UI8Array*)f_core_array_new(0, sizeof(uint8));

	f_file_保存文件块(f, 文件块, 块);
}

void C_Vec3_2D插座::f_Copy(const C_插座基类* socket) {
	C_插座基类::f_Copy(socket);

	const C_Vec3_2D插座* s = dynamic_cast<const C_Vec3_2D插座*>(socket);
	if (s) {
		//f_core_array_copy((S_Array*)m_默认值, (S_Array*)s->m_默认值);
	}
}





C_Quat_1D_插座::C_Quat_1D_插座(wstring name)
	:C_插座基类(name, E_值类型::e_Type_Quat_Array1D)
{
}

C_Quat_1D_插座::~C_Quat_1D_插座() {
}

void* C_Quat_1D_插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Quat_Array1D) {
			return dynamic_cast<C_Quat_1D_插座*>(socket)->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec4_1D) {
			auto& data = *DEF_Vec4插座_1D数据(socket);
			uint32 num = data.count;
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.ptr_userData;

			for (uint32 i = 0; i < num; ++i) {
				p1[i].dir.x = p2[i].x;
				p1[i].dir.y = p2[i].y;
				p1[i].dir.z = p2[i].z;
				p1[i].w = p2[i].w;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {
			auto& data = *DEF_Vec3_Array1D插座数据(socket);
			uint32 num = uint32(data.size());
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.data();

			for (uint32 i = 0; i < num; ++i) {
				p1[i] = *((S_Quat*)(&p2[i]));
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_F32_Array1D) {
			auto& data = *DEF_F32_Array1D插座数据(socket, 0);
			uint32 num = uint32(data.size());
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.data();

			for (uint32 i = 0; i < num; ++i) {
				p1[i] = { {},data[i] };
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_F32) {
			auto data = DEF_F32插座数据(socket, 0);
			m_Value.resize(1);
			m_Value[0] = { {},data };
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//m_Value.clear();
			//bool 引用接引用 = (data.m_插座类型 == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type) {
			case E_值类型::e_Type_Quat_Array1D:
			case E_值类型::e_Type_Vec4_Array1D:
			case E_值类型::e_Type_Vec4:
				return data;
			default:
				break;
			}
		}

	}
	return &m_Value;
}

void C_Quat_1D_插座::f_setData(void* data, int64 ID, uint8 线程ID) {
	m_Value = *((vector<S_Quat>*)data);
}


void C_Quat_1D_插座::f_释放数据() {
	m_Value.clear();
}







C_Vec球_1D_插座::C_Vec球_1D_插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_VecSphere_1D) {

}

C_Vec球_1D_插座::~C_Vec球_1D_插座() {

}

void* C_Vec球_1D_插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_VecSphere_1D) {
			return socket->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec4_1D) {
			auto& data = *DEF_Vec4插座_1D数据(socket);
			uint32 num = data.count;
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.ptr_userData;

			for (uint32 i = 0; i < num; ++i) {
				*((vec4*)&p1[i]) = p2[i];
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {
			auto& data = *DEF_Vec3_Array1D插座数据(socket);
			uint32 num = uint32(data.size());
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.data();

			for (uint32 i = 0; i < num; ++i) {
				p1[i].pos = p2[i];
				p1[i].radius = 1;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_F32_Array1D) {
			auto& data = *DEF_F32_Array1D插座数据(socket, 0);
			uint32 num = uint32(data.size());
			m_Value.resize(num);
			auto* p1 = m_Value.data();
			const auto* p2 = data.data();

			for (uint32 i = 0; i < num; ++i) {
				m_Value[i].pos.x = 0;
				m_Value[i].pos.y = 0;
				m_Value[i].pos.z = 0;
				m_Value[i].radius = data[i];
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_F32) {
			auto data = DEF_F32插座数据(socket, 0);
			m_Value.resize(1);
			m_Value[0].pos.x = 0;
			m_Value[0].pos.y = 0;
			m_Value[0].pos.z = 0;
			m_Value[0].radius = data;
		}
		else if (socket->m_Type == E_值类型::e_Type_Quat_Array1D) {
			auto data = DEF_F32插座数据(socket, 0);
			/*m_Value.resize(1);
			m_Value[0].pos.x = 0;
			m_Value[0].pos.y = 0;
			m_Value[0].pos.z = 0;
			m_Value[0].radius = data;*/
		}
		else if (socket->m_Type == E_值类型::e_插座Type_物理解算器) {
			/*auto& data = *DEF_物理解算器插座值(socket);
			if (data.m_IdType == E_物理引擎::E_物理引擎_FleX) {
				//m_Value.resize();
			}*/
		}
		else if (socket->m_Type == E_值类型::e_Type_ParticleSystem) {
			auto* 粒子 = DEF_粒子插座Value(socket);
			uint32 num = 粒子->m_粒子->m_Loc.size();
			m_Value.resize(num);

#pragma omp parallel for
			for (int32 i = 0; i < num; ++i) {
				m_Value[i].pos = 粒子->m_粒子->m_Loc[i];
				m_Value[i].radius = 粒子->m_粒子->m_Size[i];
			}
			/*auto& data = *DEF_物理解算器插座值(socket);
			if (data.m_IdType == E_物理引擎::E_物理引擎_FleX) {
				//m_Value.resize();
			}*/
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//m_Value.clear();
			//bool 引用接引用 = (data.m_插座类型 == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type) {
			case E_值类型::e_Type_Quat_Array1D:
			case E_值类型::e_Type_Vec4_Array1D:
			case E_值类型::e_Type_Vec4:
				return data;
			default:
				break;
			}
		}

	}
	return &m_Value;
}

void C_Vec球_1D_插座::f_setData(void* data, int64 ID, uint8 线程ID) {
	if (ID < 0) {
		m_Value = *((std::vector<S_VecSphere>*)data);
	}
}

void C_Vec球_1D_插座::f_释放数据() {
	m_Value.clear();
}

void C_Vec球_1D_插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<S_VecSphere>(m_Value, f);
}

void C_Vec球_1D_插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<S_VecSphere>(m_Value, f);
}











C_Array1D_iVec3插座::C_Array1D_iVec3插座(wstring name)
	:C_插座基类(name, E_值类型::e_插座Type_Vec3i_Array1D)
{
}

C_Array1D_iVec3插座::~C_Array1D_iVec3插座()
{
}

void * C_Array1D_iVec3插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_插座Type_Vec3i_Array1D) {
			return dynamic_cast<C_Array1D_iVec3插座*>(socket)->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {
			auto fvec3 = *DEF_Vec3_Array1D插座数据(socket);

			uint32 num = uint32(fvec3.size());
			m_Value.resize(num);

			vec3* p1 = fvec3.data();
			ivec3* p2 = m_Value.data();
//#pragma loop(on_vector)
//#pragma omp parallel for
			for (uint32 i = 0; i < num; ++i) {
				vec_转换(&p2[i], &p1[i]);
			}

		} else if (socket->m_Type == E_值类型::e_Type_Vec3) {
			m_Value.resize(1);
			m_Value[0] = DEF_iVec3插座数据(socket);
		}
	}
	return &m_Value;
}

void C_Array1D_iVec3插座::f_setData(void* data, int64 ID, uint8 线程ID) {
	m_Value = *((vector<ivec3>*)data);
}

void C_Array1D_iVec3插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<ivec3>(m_Value, f);
}

void C_Array1D_iVec3插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<ivec3>(m_Value, f);
}


















C_Array1D_uVec3插座::C_Array1D_uVec3插座(wstring name)
	:C_插座基类(name, E_值类型::e_Type_UI32_2D)
{
}

C_Array1D_uVec3插座::~C_Array1D_uVec3插座() {
}

void* C_Array1D_uVec3插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_UI32_2D) {
			return dynamic_cast<C_Array1D_uVec3插座*>(socket)->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_插座Type_Vec3i_Array1D) {
			auto& data = *DEF_转换为Array_iVec3插座数据(socket);
			f_vec3数据转换拷贝(m_Value, data);
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {
			auto fvec3 = *DEF_Vec3_Array1D插座数据(socket);

			uint32 num = uint32(fvec3.size());
			m_Value.resize(num);

			auto* p1 = fvec3.data();
			auto* p2 = m_Value.data();
			//#pragma loop(on_vector)
//#pragma omp parallel for
			for (uint32 i = 0; i < num; ++i) {
				vec_转换(&p2[i], &p1[i]);
			}

		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3) {
			auto v = DEF_Vec3插座数据(socket, 0);
			m_Value.resize(1);
			vec_转换(&m_Value[0], &v);
		}
		else if (socket->m_Type == E_值类型::e_Type_uVec3) {
			m_Value.resize(1);
			m_Value[0] = *DEF_uVec3插座数据(socket);
		}
	}
	return &m_Value;
}

void C_Array1D_uVec3插座::f_setData(void* data, int64 ID, uint8 线程ID) {
	m_Value = *((vector<uvec3>*)data);
}

void C_Array1D_uVec3插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<uvec3>(m_Value, f);
}

void C_Array1D_uVec3插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<uvec3>(m_Value, f);
}




















C_面顶点索引插座::C_面顶点索引插座(wstring name)
	:C_插座基类(name, E_值类型::e_Type_面顶点索引)
{
}

C_面顶点索引插座::~C_面顶点索引插座()
{
}

void C_面顶点索引插座::f_update(C_插座基类 * 连接到的输入节点, C_节点基类 * node)
{
}

void * C_面顶点索引插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_面顶点索引) {
			return dynamic_cast<C_面顶点索引插座*>(socket)->f_getData(线程ID);
		}
	}
	return &m_Value;
}

void C_面顶点索引插座::f_setData(void * data, int64 ID, uint8 线程ID)
{
	m_Value = *((vector<vector<uint32>>*)data);
}

void C_面顶点索引插座::f_resize(uint32 size)
{
}

void C_面顶点索引插座::f_释放数据() {
	m_Value.clear();
}









C_Array1D_Mat4X4插座::C_Array1D_Mat4X4插座(wstring name) :C_插座基类(name, E_值类型::e_Type_Mat4X4_Array1D) {
	m_Value.resize(1);
	m_Value[0] = f_mat44_identity();
}

C_Array1D_Mat4X4插座::~C_Array1D_Mat4X4插座() {
}

void * C_Array1D_Mat4X4插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Mat4X4_Array1D) {
			return dynamic_cast<C_Array1D_Mat4X4插座*>(socket)->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Mat4X4) {
			m_Value.resize(1);
			m_Value[0] = *DEF_Mat4X4插座数据(socket);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {
			auto& data = *DEF_物体插座_Array1D数据(socket, 线程ID);
			uint32 num = data.size();

			m_Value.resize(num);
			for (uint32 i = 0; i < num; ++i) {
				m_Value[i] = data[i]->f_get矩阵2();
			}
			if (num) {
				
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object) {
			auto& data = *DEF_物体插座数据(socket, 线程ID);
			m_Value.resize(1);
			m_Value[0] = data.f_get矩阵2();
		}
		else if (socket->m_Type == E_值类型::e_插座Type_物理体_Array1D) {
			auto& data = *DEF_物理体插座_1D数据(socket, 0);
			uint32 num = data.size();
			m_Value.resize(num);

			for (uint32 i = 0; i < num; ++i) {
				m_Value[i] = data[i]->m_Matrix;
			}
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//m_Value.clear();

			//bool 引用接引用 = (data.m_Type == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type) {
			case E_值类型::e_Type_Mat4X4_Array1D:
			case E_值类型::e_Type_Mat4X4:
				return data;
			default:
				break;
			}
		}
		else {
			m_Value.resize(1);
			m_Value[0] = f_mat44_identity();
		}
	}
	return &m_Value;
}

void C_Array1D_Mat4X4插座::f_setData(void* data, int64 ID, uint8 线程ID) {
	m_Value = *((vector<Mat44f>*)(data));
	return;
	S_引用插座数据映射* mapData = (S_引用插座数据映射*)(data);
	if (mapData->m_Type == E_值类型::e_Type_Mat4X4) {
		if (mapData->m_添加方式 == E_数据赋值方式::e_赋值_添加) {
			//m_Value.push_back(*((C_Mat44*)(mapData->m_Data)));
		}

		return;
	}
	else if (mapData->m_Type == E_值类型::e_Type_Mat4X4_Array1D) {
		cout << "施工中" << endl;

		return;
	}

	
}

void C_Array1D_Mat4X4插座::f_释放数据() {
	m_Value.clear();
}

bool C_Array1D_Mat4X4插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case e_Type_Mat3X3:
	case e_Type_Mat4X4:
	case e_Type_Mat4X4_Array1D:
	case e_Type_Mat4X4_1D:
		return true;
	}
	return false;
}




std::vector<vec3> f_vec4_to_vec3(std::vector<vec4>& v) {
	uint32 num = uint32(v.size());
	std::vector<vec3> data(num);
	auto* r = data.data();
	auto* p = v.data();
	for (uint32 i = 0; i < num; ++i) {
		r[i] = vec_转换v3(p[i]);
	}
	return data;
}





C_Mat4X4_1D插座::C_Mat4X4_1D插座(std::wstring name) : C_插座基类(name, E_值类型::e_Type_Mat4X4_1D){
	m_默认值 = (S_Mat44Array*)f_core_array_new(1, sizeof(Mat44f));
	m_转换值 = (S_Mat44Array*)f_core_array_new(1, sizeof(Mat44f));
	m_默认值->ptr_userData[0] = f_mat44_identity();
	m_转换值->ptr_userData[0] = f_mat44_identity();
	m_Value = m_默认值;
}

C_Mat4X4_1D插座::~C_Mat4X4_1D插座() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
	C_插座基类::~C_插座基类();
}

void* C_Mat4X4_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		switch(socket->m_Type){
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_Mat4X4_1D:
				return socket->f_getData(线程ID);
			case E_值类型::e_Type_Mat4X4:{
				f_core_array_resize((S_Array*)m_默认值, 1);
				m_默认值->ptr_userData[0] = *DEF_Mat4X4插座数据(socket);
			}
			default:
				return m_转换值;
		}
		return m_默认值;
	}
	return m_Value;
}

void C_Mat4X4_1D插座::f_setData(void* data, uint8 线程ID) {
	m_Value = (S_Mat44Array*)data;
}

std::string C_Mat4X4_1D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);
	if (socket) {
		if (socket->m_Type == e_Type_Mat4X4_1D || socket->m_Type == e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "_new_val_to_mat44Array";

		switch (socket->m_Type) {
		case e_Type_Mat4X4: {
			code += "S_Mat44Array* " + m_Code + " = f_Mat44_array_fromMat44_alloc(" + socket->f_getCode(loc) + ");\n";
			break;
		}
		case e_Type_Vec4: {
			code += "S_Mat44Array* " + m_Code + " = f_Mat44_array_fromMat44_alloc_过度函数(" + socket->f_getCode(loc) + ");\n";
			break;
		}
		}

		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
		//auto& c = f_getNode()->f_getThis节点树()->m_节点JIT参数;
		//uint16 常量ID = c.size();
		//m_Code = "((" + f_node_getDataTypeName(m_Type) + "*)(g参数[" + f_整数值转字符串(常量ID) + "]))";
		//f_getNode()->f_getThis节点树()->m_节点JIT参数.push_back(f_getData(0));
	}

	return code;
}

bool C_Mat4X4_1D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case E_值类型::e_Type_Array:
	case E_值类型::e_Type_Mat4X4:
	case E_值类型::e_Type_Mat4X4_1D :
	case E_值类型::e_Type_Mat4X4_Array1D :
		return true;
	}
	return false;
}





C_变换插座_Array1D::C_变换插座_Array1D(std::wstring name) : C_插座基类(name, E_值类型::e_Type_Tranform_Array1D) {
	m_Value.resize(1);
	f_TranformInit(m_Value[0]);
}
C_变换插座_Array1D::~C_变换插座_Array1D() {

}

void* C_变换插座_Array1D::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket(线程ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Tranform_Array1D) {
			return socket->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object) {
			auto& ob = *DEF_物体插座数据(socket, 线程ID);
			m_Value.resize(1);
			m_Value[0] = ob.m_变换;
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {
			auto& obs = *DEF_物体插座_Array1D数据(socket, 线程ID);
			uint32 num = obs.size();
			m_Value.resize(num);

			auto* obs_ptr = obs.data();
			auto* tranform_ptr = m_Value.data();
//#pragma omp parallel for
			for (int32 i = 0; i < num; ++i) {
				tranform_ptr[i] = obs_ptr[i]->m_变换;
			}
		}
		/*else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_转换为引用数据(socket);
			switch (data->m_Type) {
			case E_值类型::e_插座Type_Mat4X4_Array1D:
			case E_值类型::e_插座Type_Matrix4X4:
				return data;
			default:
				break;
			}
		*/
		else {
			m_Value.resize(1);
			f_TranformInit(m_Value[0]);
		}
	}
	return &m_Value;
}

void C_变换插座_Array1D::f_setData(void* data, int64 ID, uint8 线程ID) {

	S_引用插座数据映射* mapData = (S_引用插座数据映射*)(data);
	if (mapData->m_Type == E_值类型::e_Type_Tranform_Array1D) {
		if (mapData->m_添加方式 == E_数据赋值方式::e_赋值_添加) {
			m_Value.push_back(*((S_Tranform*)(mapData->m_Data)));
		}
		return;
	}
	else if (mapData->m_Type == E_值类型::e_Type_Mat4X4_Array1D) {
		cout << "C_Array1D_Tranform插座 施工中" << endl;
		return;
	}

	m_Value = *((vector<S_Tranform>*)(data));
}

void C_变换插座_Array1D::f_释放数据() {
	m_Value.clear();
}



/*C_Array1D_Tranform插座::C_Array1D_Tranform插座(std::string name) :C_插座基类(name, E_值类型::e_Type_Tranform_Array1D) {
	
}

C_Array1D_Tranform插座::~C_Array1D_Tranform插座() {

}


*/












C_Rect32f_Array1D插座::C_Rect32f_Array1D插座(std::wstring name) :C_插座基类(name, E_值类型::e_插座Type_Rect32f_Array1D) {
	m_Value = {};
}

C_Rect32f_Array1D插座::~C_Rect32f_Array1D插座() {
	
}

void* C_Rect32f_Array1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_插座Type_Rect32f_Array1D) {
			return (std::vector<S_Rect2Df>*)(socket)->f_getData(线程ID);

		}
	}

	return &m_Value;
}

void C_Rect32f_Array1D插座::f_setData(void* data, uint8 线程ID) {
	m_Value = *((std::vector<S_Rect2Df>*)data);
}

void C_Rect32f_Array1D插座::f_resize(uint32 size) {
	
}

void C_Rect32f_Array1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<S_Rect2Df>(m_Value, f);
}

void C_Rect32f_Array1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<S_Rect2Df>(m_Value, f);
}











C_线段插座_Array1D::C_线段插座_Array1D(std::wstring name) :C_插座基类(name, E_值类型::e_插座Type_Line_Array1D) {

}

C_线段插座_Array1D::~C_线段插座_Array1D() {

}

void* C_线段插座_Array1D::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_插座Type_Line_Array1D) {
			return socket->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_插座Type_Line) {
			auto& line = *DEF_线段插座数据(socket, 线程ID);
			m_Value = {line};
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {
			
			auto& v3 = *DEF_Vec3_Array1D插座数据(socket);
			uint32 num = v3.size() / 2;
			m_Value.resize(num);
			for (uint32 i = 0; i < num; ++i) {
				m_Value[i].begin = v3[i * 2];
				m_Value[i].end = v3[i * 2 + 1];
			}
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//m_Value.clear();

			//bool 引用接引用 = (data.m_Type == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type) {
			case E_值类型::e_插座Type_Line_Array1D:
			//case E_值类型::e_插座Type_Matrix4X4:
				return data;
			default:
				break;
			}
		}
		else {
			
		}
	}
	return &m_Value;
}

void C_线段插座_Array1D::f_setData(void* data, uint8 线程ID) {
	m_Value = *((std::vector<S_线段>*)data);
}

void C_线段插座_Array1D::f_释放数据() {
	m_Value.clear();
}

void C_线段插座_Array1D::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<S_线段>(m_Value, f);
}

void C_线段插座_Array1D::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<S_线段>(m_Value, f);
}









C_VN插座_Array1D::C_VN插座_Array1D(std::wstring name) :C_插座基类(name, E_值类型::e_Type_VN_Array1D) {

}

C_VN插座_Array1D::~C_VN插座_Array1D() {

}

void* C_VN插座_Array1D::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_VN_Array1D) {
			return socket->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {

			auto& v3 = *DEF_Vec3_Array1D插座数据(socket);
			uint32 num = v3.size() / 2;
			m_Value.resize(num);
			for (uint32 i = 0; i < num; ++i) {
				//m_Value[i].begin = v3[i * 2];
				//m_Value[i].end = v3[i * 2 + 1];
			}
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//m_Value.clear();

			//bool 引用接引用 = (data.m_Type == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type) {
			case E_值类型::e_Type_VN_Array1D:
				return data;
			default:
				break;
			}
		}
		else {

		}
	}
	return &m_Value;
}

void C_VN插座_Array1D::f_setData(void* data, uint8 线程ID) {
	m_Value = *((std::vector<S_VN>*)data);
}

void C_VN插座_Array1D::f_释放数据() {
	m_Value.clear();
}

void C_VN插座_Array1D::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<S_VN>(m_Value, f);
}

void C_VN插座_Array1D::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<S_VN>(m_Value, f);
}







C_Cube_1D插座::C_Cube_1D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Cube_Array1D) {

}

C_Cube_1D插座::~C_Cube_1D插座() {

}

void* C_Cube_1D插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Cube_Array1D) {
			return socket->f_getData(线程ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Vec3_Array1D) {

			auto& v3 = *DEF_Vec3_Array1D插座数据(socket);
			uint32 num = v3.size() / 2;
			m_Value.resize(num);
			for (uint32 i = 0; i < num; ++i) {
				m_Value[i].pos = {};
				m_Value[i].size = v3[i];
			}
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto* data = DEF_引用插座数据(socket, 0);
			//bool 引用接引用 = (data.m_Type == E_值类型::e_插座Type_引用数据);
			switch (data->m_Type) {
			case E_值类型::e_Type_Cube_Array1D:
				return data;
			default:
				break;
			}
		}
		else {
			m_Value.clear();
		}
	}
	return &m_Value;
}

void C_Cube_1D插座::f_setData(void* data, uint8 线程ID) {
	m_Value = *((std::vector<S_Cube>*)data);
}

void C_Cube_1D插座::f_resize(uint32 size) {
	m_Value.resize(size);
}

void C_Cube_1D插座::f_读取(FILE* f) {
	C_插座基类::f_读取(f);
	f_矢量数据载入<S_Cube>(m_Value, f);
}

void C_Cube_1D插座::f_写入(FILE* f) {
	C_插座基类::f_写入(f);
	f_写出矢量数据<S_Cube>(m_Value, f);
}







C_UI32_2D插座::C_UI32_2D插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_UI32_2D) {
	m_默认值 = (S_UI32Array2D*)f_core_array_new(0, sizeof(S_UI32Array*), true);
	m_转换值 = (S_UI32Array2D*)f_core_array_new(0, sizeof(S_UI32Array*), true);

	m_Value = m_默认值;
}

C_UI32_2D插座::~C_UI32_2D插座() {
	f_array_销毁UI32_2D(m_默认值);
	f_array_销毁UI32_2D(m_转换值);
}

void* C_UI32_2D插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		switch (socket->m_Type) {
			case E_值类型::e_Type_Array:
			case E_值类型::e_Type_UI32_2D: return socket->f_getData(0);

			//case E_值类型::e_Type_Vec2: {
			//	m_转换值->ptr_userData[0] = *DEF_Vec2插座数据(socket, 0);
			//	break;
			//}
			//
			//case E_值类型::e_Type_F32: {
			//	float32 v = *DEF_F32插座数据(socket, 0);
			//	m_转换值->ptr_userData[0] = { v,v };
			//	break;
			//}
			default:
				break;
		}

		m_Value = m_转换值;
	}
	else {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_UI32_2D插座::f_setData(void* data, uint8 线程ID) {
	m_Value = (S_UI32Array2D*)data;
}

std::string C_UI32_2D插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(0);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_UI32_2D || socket->m_Type == E_值类型::e_Type_Array) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + f_整数值转字符串(loc) + "new_val_to_ui32_2d";
		code += DEF_S(S_UI32Array2D*)" " + m_Code + ";\n";
		switch (socket->m_Type) {
			default:
				m_Code = "";
		}

		m_pNode->m_ReleaseCode += DEF_S(f_array_销毁UI32_2D)"(" + m_Code + ");\n";
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "(&" + m_Code + ")";
	}

	return code;
}

bool C_UI32_2D插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
		case e_Type_UI32_1D:
		case e_Type_UI32_2D:
		case e_Type_Array:
			return true;
	}
	return false;
}







